package com.wx.JerseySpring.filter;


import com.sun.jersey.core.reflection.MethodList;
import com.wx.JerseySpring.context.Context;
import com.wx.JerseySpring.entity.User;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by Administrator on 2016/11/17.
 */
public class IndexFilter implements Filter{

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest)servletRequest;
        HttpServletResponse response = (HttpServletResponse) servletResponse;
        // 在这个拦截器里面配置一些字符编码为utf-8
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
//        User user = (User) request.getSession().getAttribute(Context.CONTEXT_USER);
        response.sendRedirect("/demo/index/index.html");
    }

    @Override
    public void destroy() {

    }
}
